﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using transportsystem.DTO;
using UTIL;
namespace transportsystem.DAO
{
    public class KhachHangDAO
    {
        public static DataTable getKhachHangList(params SqlParameter[] Params)
        {
            SqlDataAccessHelper.ConnectSQLServer();
            string procName = "sp_TraCuuKhachHang";
            DataSet ds = SqlDataAccessHelper.LoadDataWithParameter(procName, Params);
            if (ds != null)
                return ds.Tables[0];
            return null;
        }
        public static DataTable getLoaiKhachHangList()
        {
            SqlDataAccessHelper.ConnectSQLServer();
            string procName = "sp_DanhSachLoaiKh";
            DataSet ds = SqlDataAccessHelper.LoadDataWithParameter(procName);
            if (ds != null)
                return ds.Tables[0];
            return null;
        }
        public static int thaoTacKhachHang(params SqlParameter[] Params)
        {

            SqlDataAccessHelper.ConnectSQLServer();
            string procName = "sp_khachhang";
            DataSet ds = SqlDataAccessHelper.LoadDataWithParameter(procName, Params);
            if (ds != null)
                return 1;
            return 0;

        }
        public static bool deleteKhachHang(KhachHang kh)
        {
            SqlCommand cmd = SqlDataAccessHelper.CreateCommand("sp_XoaKhachHang");
            cmd.Parameters.Add("@makh", SqlDbType.Int).Value = kh.Makh;
            return SqlDataAccessHelper.ExecCmd(cmd);
        }
        public static DataTable getKhachHangID(params SqlParameter[] Params)
        {
            SqlDataAccessHelper.ConnectSQLServer();
            string procName = "sp_TraCuuKhachHangID";
            DataSet ds = SqlDataAccessHelper.LoadDataWithParameter(procName, Params);
            if (ds != null)
                return ds.Tables[0];
            return null;
        }
        public static bool updateSoLanMuaVe(params SqlParameter[] Params)
        {
            SqlDataAccessHelper.ConnectSQLServer();
            string procName = "sp_updateSoLanMuaVe";
            DataSet ds = SqlDataAccessHelper.LoadDataWithParameter(procName, Params);
            if (ds != null)
                return true;
            return false;
        }
        public static DataSet getKhachHangList2(params SqlParameter[] Params)
        {
            SqlDataAccessHelper.ConnectSQLServer();
            string procName = "sp_TraCuuKhachHang2";
            DataSet ds = SqlDataAccessHelper.LoadDataWithParameter(procName, Params);
            if (ds != null)
                return ds;
            return null;
        }
        public static bool updateSoLanHuyVe(params SqlParameter[] Params)
        {
            SqlDataAccessHelper.ConnectSQLServer();
            string procName = "sp_updateSoLanHuyVe";
            DataSet ds = SqlDataAccessHelper.LoadDataWithParameter(procName, Params);
            if (ds != null)
                return true;
            return false;
        }

      
    }
}
